﻿/*
 * Created by SharpDevelop.
 * User: Administrator
 * Date: 2011-2-2
 * Time: 23:52
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace sharpMTKReader
{
	/// <summary>
	/// Description of MTKDataFile.
	/// </summary>
	public class MTKDataFile
	{
		public MTKDataFile()
		{
		}
		
		byte[] _DataBuffer;
		System.IO.BinaryReader _DataReader;
		public bool LoadFile(string filePath)
		{
			bool ok = false;
			System.IO.FileStream fs = new System.IO.FileStream(filePath,System.IO.FileMode.Open);
			_DataReader = new System.IO.BinaryReader(fs);
			
			return ok;
			
		}
		
		public bool CheckFileHeader()
		{
			bool ok = false;
			
			char[] fhsample = new char[18]{'P','H','O','N','E','S','U','I','T','E',' ','P','R','O','F','I','L','E'};
			byte[] fhdata = System.Text.Encoding.ASCII.GetBytes(fhsample);
			
			byte[] fheader = _DataReader.ReadBytes(18);
	        
			char[] fh = System.Text.Encoding.ASCII.GetChars(fheader);
			ok = DataEquals(fhdata,fheader);
			
			return ok;
		}
		
		private bool DataEquals(byte[] b1, byte[] b2)
		{
			if (b1 == null || b2 == null) return false;	

			if (b1.Length != b2.Length) return false;

			for (int i = 0; i < b1.Length; i++)
				if (b1[i] != b2[i])
						return false;
			return true;
		}
	}
}
